package com.bh.controller;


import com.bh.remote.UserRemoteClient;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class PlanController {

    @Autowired(required = false)
    UserRemoteClient userRemoteClient;

   // @HystrixCommand(defaultFallback = "error")
    @GetMapping("/plan/query")
    public Map query(){
        Map map=new HashMap();
        map.put("planname","生产一架飞机");
       /* userRemoteClient.testGetMap(map);
        userRemoteClient.testPostMap(map);



        User u=new User("张三",23);
        userRemoteClient.testPostUser(u);
        userRemoteClient.testStringQueryUser(u);
  userRemoteClient.login("abc","123");*/


        Map user=userRemoteClient.queryUser("1");

        map.put("user",user);

        return map;
    }
    public Map error(){
        Map map=new HashMap();
        map.put("code",0);
        map.put("msg","服务器繁忙,请稍后重试");
        return map;
    }
}
